package com.cloudcentral.controller;

import com.cloudcentral.entity.Radio;
import com.cloudcentral.entity.query.RadioQuery;
import com.cloudcentral.entity.vo.RadioDetailVO;
import com.cloudcentral.entity.vo.RadioVO;
import com.cloudcentral.exception.FailureException;
import com.cloudcentral.service.RadioService;
import com.cloudcentral.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 台站信息表 前端控制器
 * </p>
 *
 * @author Administrator
 * @since 2023-11-22
 */
@Slf4j
@RestController
@RequestMapping("/radio")
@Tag(name = "台站信息")
public class RadioController extends BaseController {
  private final RadioService radioService;

  @Autowired
  public RadioController(RadioService radioService) {
    this.radioService = radioService;
  }

  @PostMapping("/submit")
  @Operation(summary = "提交")
  public Result<Radio> submit(Radio radio) throws FailureException {
    return Result.ok(radioService.submit(radio));
  }

  @DeleteMapping("/delete")
  @Operation(summary = "删除")
  public Result<Boolean> delete(Integer id) {
    return Result.ok(radioService.delete(id));
  }

  @GetMapping("/select")
  @Operation(summary = "查询")
  public Result<RadioDetailVO> select(Integer id) throws Exception {
    return Result.ok(radioService.select(id));
  }

  @GetMapping("/listAll")
  @Operation(summary = "集合")
  public Result<List<RadioVO>> listAll(RadioQuery query) {
    return Result.ok(radioService.listAll(query));
  }
}